﻿using System;
using System.Collections.Generic;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;
using Object = UnityEngine.Object;

namespace XMainClient
{
	// Token: 0x02000BC6 RID: 3014
	internal class BarrageItem : DlgBehaviourBase
	{
		// Token: 0x0600AC1C RID: 44060 RVA: 0x001F9EC8 File Offset: 0x001F80C8
		public void Awake()
		{
			this.cacheTrans = base.transform;
			this.label = (this.cacheTrans.GetComponent("XUILabel") as IXUILabel);
			this.outline = this.cacheTrans.Find("me").gameObject;
			this.m_colors = XSingleton<XGlobalConfig>.singleton.GetStringList("BarrageColors");
			this.m_sizes = XSingleton<XGlobalConfig>.singleton.GetIntList("BarrageSize");
		}

		// Token: 0x0600AC1D RID: 44061 RVA: 0x001F9F44 File Offset: 0x001F8144
		public void Make(string txt, BarrageQueue queue, bool outl)
		{
			this.mQueue = queue;
			int index = UnityEngine.Random.Range(0, this.m_colors.Count);
			int fontSize = UnityEngine.Random.Range(this.m_sizes[0], this.m_sizes[1]);
			txt = XSingleton<XCommon>.singleton.StringCombine(this.m_colors[index], txt, "[-]");
			this.label.SetText(txt);
			this.label.spriteDepth = queue.depth;
			this.label.fontSize = fontSize;
			this.label.SetDepthOffset(queue.queueCnt);
			this.labelWidth = this.label.spriteWidth;
			this.start = base.transform.localPosition;
			this.end = new Vector3(this.start.x - (float)(this.labelWidth * 2) - 1136f, this.start.y, this.start.z);
			this.t_start = Time.time;
			this.t_cnt = (float)BarrageDlg.MOVE_TIME;
			this.outline.SetActive(outl);
		}

		// Token: 0x0600AC1E RID: 44062 RVA: 0x001FA068 File Offset: 0x001F8268
		public void Update()
		{
			bool flag = DlgBase<BarrageDlg, BarrageBehaviour>.singleton.IsOutScreen(this.cacheTrans.localPosition.x + (float)this.labelWidth);
			if (flag)
			{
				bool flag2 = this.mQueue != null;
				if (flag2)
				{
					this.mQueue.FadeOut(this);
				}
				DlgBase<BarrageDlg, BarrageBehaviour>.singleton.RecycleItem(this);
			}
			else
			{
				bool flag3 = this.cacheTrans != null;
				if (flag3)
				{
					this.cacheTrans.localPosition = Vector3.Lerp(this.start, this.end, (Time.time - this.t_start) / this.t_cnt);
				}
			}
		}

		// Token: 0x0600AC1F RID: 44063 RVA: 0x001FA108 File Offset: 0x001F8308
		public void Drop()
		{
			bool flag = base.gameObject != null;
			if (flag)
			{
				Object.Destroy(base.gameObject);
			}
		}

		// Token: 0x040040B6 RID: 16566
		private List<string> m_colors = new List<string>();

		// Token: 0x040040B7 RID: 16567
		private List<int> m_sizes = new List<int>();

		// Token: 0x040040B8 RID: 16568
		public IXUILabel label;

		// Token: 0x040040B9 RID: 16569
		public GameObject outline;

		// Token: 0x040040BA RID: 16570
		public Transform cacheTrans;

		// Token: 0x040040BB RID: 16571
		private BarrageQueue mQueue;

		// Token: 0x040040BC RID: 16572
		private int labelWidth = 10;

		// Token: 0x040040BD RID: 16573
		private Vector3 start;

		// Token: 0x040040BE RID: 16574
		private Vector3 end;

		// Token: 0x040040BF RID: 16575
		private float t_start;

		// Token: 0x040040C0 RID: 16576
		private float t_cnt;
	}
}
